package net.fivegoods.web;

import javax.ws.rs.DELETE;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

import net.fivegoods.entity.impl.slim3.MissionModel;

@Path("/missions")
public class Missions {
    
    @GET
    @Path("/{key}")
    public MissionModel get(@PathParam("key") String encodedKey) {
        return MissionModel.getByKeyString(encodedKey);
    }

    @POST
    public MissionModel create() {
        MissionModel mission = new MissionModel();
        mission.save();
        return mission;
    }
    @PUT
    public MissionModel update(@FormParam("key") String encodedKey) {
        MissionModel mission = MissionModel.getByKeyString(encodedKey);
        mission.save();
        return mission;
    }
    @DELETE
    @Path("/{key}")
    public void delete(@PathParam("key") String encodedKey) {
        MissionModel.deleteByKeyString(encodedKey);
    }
}
